import { useRequest } from './request'
import type {
  AddColumnParams,
  ColumnExistsParams,
  DropColumnParams,
  RenameColumnParams,
  CreateTableParams,
  DropTableParams,
  TableExistsParams,
  TruncateTableParams,
  RenameTableParams,
  GetTableColumnsParams,
  InsertRecordParams,
  UpdateRecordParams,
  DeleteRecordParams,
  SaveEntityParams,
  UpdateEntityParams,
  DeleteEntityParams,
  PaginateEntityParams,
  AggregateParams,
  SelectRecordsParams,
  SelectOneRecordParams,
  ExecuteRawSqlParams,
  SelectJoinRecordParams,
  FixedTableParams
} from '@/database/define/params'

export const useOverview = <R = any>(option: Partial<RequestOption<void>>): RequestReactive<void, R> => {
  return useRequest<void, R>({ key: 'overview', ...option })
}

export const useAddColumn = <R = any>(option: Partial<RequestOption<AddColumnParams>>): RequestReactive<AddColumnParams, R> => {
  return useRequest<AddColumnParams, R>({ key: 'add_column', ...option })
}

export const useColumnExists = <R = any>(option: Partial<RequestOption<ColumnExistsParams>>): RequestReactive<ColumnExistsParams, R> => {
  return useRequest<ColumnExistsParams, R>({ key: 'column_exists', ...option })
}

export const useDropColumn = <R = any>(option: Partial<RequestOption<DropColumnParams>>): RequestReactive<DropColumnParams, R> => {
  return useRequest<DropColumnParams, R>({ key: 'drop_column', ...option })
}

export const useRenameColumn = <R = any>(option: Partial<RequestOption<RenameColumnParams>>): RequestReactive<RenameColumnParams, R> => {
  return useRequest<RenameColumnParams, R>({ key: 'rename_column', ...option })
}

export const useCreateTable = <R = any>(option: Partial<RequestOption<CreateTableParams>>): RequestReactive<CreateTableParams, R> => {
  return useRequest<CreateTableParams, R>({ key: 'create_table', ...option })
}

export const useFixedTable = <R = any>(option: Partial<RequestOption<CreateTableParams>>): RequestReactive<FixedTableParams, R> => {
  return useRequest<FixedTableParams, R>({ key: 'fixed_table', ...option })
}

export const useDropTable = <R = any>(option: Partial<RequestOption<DropTableParams>>): RequestReactive<DropTableParams, R> => {
  return useRequest<DropTableParams, R>({ key: 'drop_table', ...option })
}

export const useTableExists = <R = any>(option: Partial<RequestOption<TableExistsParams>>): RequestReactive<TableExistsParams, R> => {
  return useRequest<TableExistsParams, R>({ key: 'table_exists', ...option })
}

export const useTruncateTable = <R = any>(option: Partial<RequestOption<TruncateTableParams>>): RequestReactive<TruncateTableParams, R> => {
  return useRequest<TruncateTableParams, R>({ key: 'truncate_table', ...option })
}

export const useRenameTable = <R = any>(option: Partial<RequestOption<RenameTableParams>>): RequestReactive<RenameTableParams, R> => {
  return useRequest<RenameTableParams, R>({ key: 'rename_table', ...option })
}

export const useGetTableColumns = <R = any>(option: Partial<RequestOption<GetTableColumnsParams>>): RequestReactive<GetTableColumnsParams, R> => {
  return useRequest<GetTableColumnsParams, R>({ key: 'get_table_columns', ...option })
}

export const useInsertRecord = <R = any>(option: Partial<RequestOption<InsertRecordParams>>): RequestReactive<InsertRecordParams, R> => {
  return useRequest<InsertRecordParams, R>({ key: 'insert_record', ...option })
}

export const useUpdateRecord = <R = any>(option: Partial<RequestOption<UpdateRecordParams>>): RequestReactive<UpdateRecordParams, R> => {
  return useRequest<UpdateRecordParams, R>({ key: 'update_record', ...option })
}

export const useDeleteRecord = <R = any>(option: Partial<RequestOption<DeleteRecordParams>>): RequestReactive<DeleteRecordParams, R> => {
  return useRequest<DeleteRecordParams, R>({ key: 'delete_record', ...option })
}

export const useSaveEntity = <R = any>(option: Partial<RequestOption<SaveEntityParams>>): RequestReactive<SaveEntityParams, R> => {
  return useRequest<SaveEntityParams, R>({ key: 'save_entity', ...option })
}

export const useUpdateEntity = <R = any>(option: Partial<RequestOption<UpdateEntityParams>>): RequestReactive<UpdateEntityParams, R> => {
  return useRequest<UpdateEntityParams, R>({ key: 'update_entity', ...option })
}

export const useDeleteEntity = <R = any>(option: Partial<RequestOption<DeleteEntityParams>>): RequestReactive<DeleteEntityParams, R> => {
  return useRequest<DeleteEntityParams, R>({ key: 'delete_entity', ...option })
}

export const usePaginateEntity = <R = any>(option: Partial<RequestOption<PaginateEntityParams>>): RequestReactive<PaginateEntityParams, R> => {
  return useRequest<PaginateEntityParams, R>({ key: 'paginate_entity', ...option })
}

export const usePaginateEntityPlus = <R = any>(option: Partial<RequestOption<PaginateEntityParams>>): RequestReactive<PaginateEntityParams, R> => {
  return useRequest<PaginateEntityParams, R>({ key: 'paginate_entity_plus', ...option })
}

export const useAggregateAvg = <R = any>(option: Partial<RequestOption<AggregateParams>>): RequestReactive<AggregateParams, R> => {
  return useRequest<AggregateParams, R>({ key: 'aggregate_avg', ...option })
}

export const useAggregateCount = <R = any>(option: Partial<RequestOption<AggregateParams>>): RequestReactive<AggregateParams, R> => {
  return useRequest<AggregateParams, R>({ key: 'aggregate_count', ...option })
}

export const useAggregateMax = <R = any>(option: Partial<RequestOption<AggregateParams>>): RequestReactive<AggregateParams, R> => {
  return useRequest<AggregateParams, R>({ key: 'aggregate_max', ...option })
}

export const useAggregateMin = <R = any>(option: Partial<RequestOption<AggregateParams>>): RequestReactive<AggregateParams, R> => {
  return useRequest<AggregateParams, R>({ key: 'aggregate_min', ...option })
}

export const useAggregateSum = <R = any>(option: Partial<RequestOption<AggregateParams>>): RequestReactive<AggregateParams, R> => {
  return useRequest<AggregateParams, R>({ key: 'aggregate_sum', ...option })
}

export const useSelectJoinRecord = <R = any>(option: Partial<RequestOption<SelectJoinRecordParams>>): RequestReactive<SelectJoinRecordParams, R> => {
  return useRequest<SelectJoinRecordParams, R>({ key: 'select_join', ...option })
}

export const useSelectOneRecord = <R = any>(option: Partial<RequestOption<SelectOneRecordParams>>): RequestReactive<SelectOneRecordParams, R> => {
  return useRequest<SelectOneRecordParams, R>({ key: 'select_one_record', ...option })
}

export const useSelectRecords = <R = any>(option: Partial<RequestOption<SelectRecordsParams>>): RequestReactive<SelectRecordsParams, R> => {
  return useRequest<SelectRecordsParams, R>({ key: 'select_records', ...option })
}

export const useExecuteRawSql = <R = any>(option: Partial<RequestOption<ExecuteRawSqlParams>>): RequestReactive<ExecuteRawSqlParams, R> => {
  return useRequest<ExecuteRawSqlParams, R>({ key: 'execute_raw_sql', ...option })
}

export const useGetColumnTypes = <R = any>(option: Partial<RequestOption<void>>): RequestReactive<void, R> => {
  return useRequest<void, R>({ key: 'get_column_types', ...option })
}

export const useGetPrimaryKey = <R = any>(option: Partial<RequestOption<void>>): RequestReactive<void, R> => {
  return useRequest<void, R>({ key: 'get_primary_key', ...option })
}

export const useGetTables = <R = any>(option: Partial<RequestOption<void>>): RequestReactive<void, R> => {
  return useRequest<void, R>({ key: 'get_tables', ...option })
}

export const useGetUuid = <R = any>(option: Partial<RequestOption<void>>): RequestReactive<void, R> => {
  return useRequest<void, R>({ key: 'get_uuid', ...option })
}

export const useGetTableUsed = <R = any>(option: Partial<RequestOption<void>>): RequestReactive<GetTableUsedParams, R> => {
  return useRequest<GetTableUsedParams, R>({ key: 'get_tables_used', ...option })
}

export const useSetTableUsed = <R = any>(option: Partial<RequestOption<void>>): RequestReactive<SetTableUsedParams, R> => {
  return useRequest<SetTableUsedParams, R>({ key: 'set_tables_used', ...option })
}